package io.renren.modules.pro.controller;

import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;
import io.renren.modules.pro.entity.ItemTaskEntity;
import io.renren.modules.pro.service.ItemTaskService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.Map;


/**
 *
 *
 * @author zhangyue
 * @email zhangyue086@163.com
 * @date 2022-04-25 15:48:59
 */
@RestController
@RequestMapping("/pro/itemtask")
public class ItemTaskController {
	@Autowired
	private ItemTaskService itemTaskService;

	/**
	 * 列表
	 */
	@RequestMapping("/list")
	@RequiresPermissions("itemtask:list")
	public R list(@RequestParam Map<String, Object> params){
		//查询列表数据
		PageUtils page = itemTaskService.queryPage(params);
        return R.ok().put("page", page);
	}


	/**
	 * 信息
	 */
	@RequestMapping("/info/{id}")
	@RequiresPermissions("itemtask:info")
	public R info(@PathVariable("id") Long id){
		ItemTaskEntity itemTask = itemTaskService.getById(id);
		return R.ok().put("itemTask", itemTask);
	}

	/**
	 * 保存
	 */
	@RequestMapping("/save")
	@RequiresPermissions("itemtask:save")
	public R save(@RequestBody ItemTaskEntity itemTask){
		itemTaskService.save(itemTask);
		return R.ok();
	}

	/**
	 * 修改
	 */
	@RequestMapping("/update")
	@RequiresPermissions("itemtask:update")
	public R update(@RequestBody ItemTaskEntity itemTask){
		itemTaskService.updateById(itemTask);
		return R.ok();
	}

	/**
	 * 删除
	 */
	@RequestMapping("/delete")
	@RequiresPermissions("itemtask:delete")
	public R delete(@RequestBody Long[] ids){
		itemTaskService.removeByIds(Arrays.asList(ids));
		return R.ok();
	}

}
